﻿
drop table t1;
create table t1(a bigint,b bigint);
insert into t1 select n,(random()*200000)::int AS id
from 
    generate_series(1,100000000) as x(n);

SELECT * FROM t1 limit 10 ;

EXPLAIN ANALYSE SELECT * FROM t1 ;    -- 55 secondes

EXPLAIN ANALYSE SELECT * FROM t1 where b=1;  -- 7.4 secondes  

SET max_parallel_workers_per_gather TO 0;
EXPLAIN ANALYSE SELECT * FROM t1 where b=1;  -- 6 secondes

SET max_parallel_workers_per_gather TO 2;
EXPLAIN ANALYSE SELECT * FROM t1 where b=1;  -- 2.5 secondes

SET parallel_tuple_cost TO DEFAULT;
SET max_parallel_workers_per_gather TO 8;
EXPLAIN ANALYSE SELECT * FROM t1 where b=1;  -- 1.6 secondes

